package com.meetingshow.action.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.meetingshow.action.MeetingShowAction;
import com.meetingshow.form.user.UserForm;
import com.meetingshow.service.user.IUserSVC;
import com.meetingshow.utils.UIServiceFactory;

public class AddUserAction extends MeetingShowAction {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse res)
			throws Exception {
		Logger logger = Logger.getLogger(AddUserAction.class);
		logger.info("AddUserAction");

		try {
			UserForm userForm = (UserForm)form;
			IUserSVC userSVC = UIServiceFactory.getUserSVC();
			userSVC.insertUser(userForm.getUserName(), userForm.getPassword());
			res.getWriter().print(userForm.getUserName());
			System.out.println("User add Successfully-CONFIRM");
		
			

		} catch (Exception e) {
			logger.error(e.toString());
			res.getWriter().println(e.toString());
		}
		return null;
	}
}
